<template>
	<view class="page">
		<CustomNav :isBack="true" color="#fff" :topBgColor="topBgColor" title="招工用工"></CustomNav>
		<view :style="'margin-top:'+mt" class="content">
			<view @click="navigate('/page_pack/recruitment/release')" class="release-btn">
				<view class="title-block">
					<image src="@/static/images/release.png" class="release-icon"></image>
					<view class="title FZHZGBJ">发布职位</view>
				</view>
				<view class="sub-title">农业企业可发布招工用工需求</view>
			</view>
			<view class="content-block">
				<view class="search-block">
					<input placeholder="请输入关键字" v-model="searchName" class="search-item" @confirm="search" />
					<view class="search">搜索</view>
				</view>
				<view class="list-block">
					<template v-if="list.length>0">
						<view class="entrepreneurship-item" :style="style" v-for="item in list"
							@click="navigate('/page_pack/entrepreneurship/village?id='+item.id+'&type=1')">
							<view class="entrepreneurship-info">
								<view class="title">{{item.title}}</view>
								<view class="address">月薪：<text style="color: #64B548;">{{item.salaryLevel}}</text>
								</view>
							</view>
						</view>
					</template>
					<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
					<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util'
	import {
		getRecruitList
	} from '@/api/article';
	import WorkList from '@/components/WorkList.vue'
	export default {
		components: {
			WorkList
		},
		data() {
			return {
				topBgColor: 'rgba(0,0,0,0)',
				conf: {
					page: 1,
					limit: 20,
				},
				more: true,
				list: [],
			}
		},
		watch: {

		},
		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getRecruitList(this.conf).then(res => {
					let list = res.list || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.count);
				}).finally(() => {
					uni.stopPullDownRefresh();
				})
			}
		},
		onPullDownRefresh() {
			this.handleRefresh();
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				this.getList();
			}
		},
		onLoad() {
			this.getList(true)
		}
	}
</script>

<style lang="scss" lang="scss">
	.page {
		overflow: hidden;
		height: 100%;
		background-image: linear-gradient(to bottom, #68C759, #F8F8F8 400px, #F8F8F8 400px, #F8F8F8);
		background-repeat: no-repeat;

		.content {

			.release-btn {
				position: absolute;
				width: calc(100% - 60rpx);
				transform: translate(-50%, -50%);
				left: 50%;
				top: 300rpx;
				height: 220rpx;
				background: linear-gradient(to right, #66BD59, #6BD559);
				border-radius: 8px;
				z-index: 2;
				display: flex;
				flex-direction: column;
				justify-content: center;
				padding-left: 60rpx;
				box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.5);

				.title-block {
					display: flex;
					align-items: center;
					margin-bottom: 30rpx;

					.release-icon {
						width: 50rpx;
						height: 50rpx;
						margin-right: 20rpx;
						background-color: #fff;
						padding: 10rpx;
						border-radius: 50%;
					}

					.title {
						color: #fff;
						font-size: 40rpx;
					}
				}

				.sub-title {
					color: #fff;
					font-size: 28rpx;
				}
			}

			.content-block {
				position: relative;
				z-index: 1;
				margin-top: 280rpx;
				width: 100%;
				border-radius: 20px 20px 0 0;
				background: #F7F6F9;
				padding: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				flex-wrap: wrap;

				.search-block {
					width: 100%;
					background: #fff;
					color: #999;
					font-size: 28rpx;
					display: flex;
					flex-direction: row;
					align-items: center;
					padding: 0 20rpx;
					border-radius: 40rpx;
					height: 80rpx;

					.search {
						flex-grow: 0;
						display: flex;
						justify-content: center;
						align-items: center;
						width: 120rpx;
						border-radius: 50rpx;
						height: 55rpx;
						padding-bottom: 5rpx;
						color: #FFFFFF;
						background: linear-gradient(90deg, #67C059 0%, #6BD459 100%);
						font-size: 28rpx;
					}

					input {
						flex-grow: 1;
					}
				}

				.menu-block {
					width: calc(100% - 30rpx);
					height: 100%;
					overflow-x: scroll;
					padding: 0 10rpx;
					display: flex;
					align-items: center;
					margin-top: 30rpx;

					.menu-item {
						width: auto;
						margin-right: 30rpx;
						background: #fff;
						padding: 10rpx;
						border-radius: 4rpx;
						white-space: nowrap;
						display: flex;
						flex-direction: row;
					}

					.menu-item:last-child {
						margin-right: 0;
					}

					.menu-item.active {
						color: #64B548;
					}
				}

				.list-block {
					width: 100%;
					margin-top: 50rpx;

					.entrepreneurship-item {
						width: 100%;
						height: 220rpx;
						border-radius: 8px;
						background: #fff;
						display: flex;
						align-items: center;
						padding: 30rpx;
						margin-bottom: 20rpx;

						.entrepreneurship-cover {
							width: 160rpx;
							height: 160rpx;
							border-radius: 8px;
							margin-right: 20rpx;
							background-color: #f5f5f5;
						}

						.entrepreneurship-info {
							//width: calc(100% - 180rpx);
							height: 100%;
							display: flex;
							flex-direction: column;
							justify-content: center;
							position: relative;

							.status {
								position: absolute;
								right: 0;
								bottom: 0;
							}

							.title {
								width: 100%;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;
								font-size: 34rpx;
								font-weight: bold;
								margin-bottom: 30rpx;
							}

							.address {
								width: 100%;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;
								color: #999;
							}
						}
					}
				}
			}
		}
	}
</style>